﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>




<div id="diary">
<a class="pointer"><img id="biaoqing" src="../../Content/Images/feeling/smile.jpg"></a>
<input type="hidden" id="hidefeel" value="smile" />
<textarea id="diaryarea" cols="15" rows="4"></textarea>

<p id="huanbiaoqing"><a class="pointer" >换表情</a></p>
<p id="zishu"><a id="fontcount">0</a>/100</p>
<button id="fabu"></button>
</div>





<div id="mood"></div>

<script src="../../Content/Js/mood.js" type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function () {
        for (i in mood) $('#mood').append('<img alt="' + mood[i].title + '" title="' + mood[i].title + '" src="../Content/Images/feeling/' + mood[i].src + '.jpg" />');
        $('#mood a').click(function (event) {
            $('#mood').hide();
            event.stopPropagation();
        });
        $('#mood img').click(function () {
            $('#mood').hide();
            $('#biaoqing').attr('src', this.src);
            var begin = this.src.indexOf('feeling/');
            var end = this.src.indexOf('.jpg');
            var str = this.src.substring(begin + "feeling/".length, end);
            $('#hidefeel').val(str);
            //change the recall
        });
        $('#huanbiaoqing,#biaoqing').click(function () {
            $('#mood').show();
        });



        //我自己的代码
        $('#fabu').click(function () {

            if ($('#diaryarea').val().length > 140 || $('#diaryarea').val().length <= 0) {
                return;
            }
            var _content = encodeURI($('#diaryarea').val());

            var _feel = encodeURI($('#hidefeel').val());

            $.ajax({
                type: 'POST',
                url: "http://" + window.location.host + "/Feeling/AddFeeling",
                data: { content: _content, feel: _feel },
                success: function (data) {
                    if (data.indexOf('成功') > 0) {
                        $('#diaryarea').val("");
                        $('#fontcount').text("0");

                    }
                    else { jAlert(data); }

                },
                error: function () {
                    jAlert('网络不给力啊');
                }
            });
        });



    });
</script>
<style type="text/css">
#mood { background-color:#adc9a1;}
</style>

